
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections.Generic;
using System.Text;

using Swaf;
using Swaf.BizObj;
using Swaf.BizRule;
using Swaf.Gui;
using Swaf.Security;

namespace Articles.Gui
{
	public class ArticleTranslationBizProc : Articles.Gui.ArticleManagementBizProc
	{
		public ArticleTranslationBizProc(ActiveBizProc activeBP)
			: base(activeBP)
		{
		}
		protected void switchTranslationMode()
		{
			this.showData(ForceLevel.mustShowGetDetailsDataIfNeeded);
		}
		protected override void setupRuleNames()
		{
			base.setupRuleNames();
			base.m_updateBizObjRule = "updateArticleTranslation";
		}
		protected override object[] getUpdateBizRuleParameters(IBizObj bizObj)
		{
			object id = m_procState.get("locId");
			return new object[] { bizObj, id as Swaf.BGuid.Guid };
		}
		protected override void setupActions()
		{
			base.setupActions();
			Actions.addAction(new GenericAction("SwitchTranslation", false, switchTranslationMode, this));
		}
		public override void updateActionState()
		{
			base.updateActionState();
			((GenericAction)Actions["SwitchTranslation"]).Availability = CanEdit ? ActionAvailability.enabled : ActionAvailability.none;
		}
		public override Privileges CurrentEditPrivilege
		{
			get
			{
				return CurrentPrincipal.getPrivilege("AppFunctions.ManageArticles");
			}
		}
	}
}
